//
//  StringValueFormatter.m
//  XTCloud
//
//  Created by QA on 2018/7/31.
//  Copyright © 2018年 ShangHai HaoLei Software Technology Co., Ltd. All rights reserved.
//

#import "StringValueFormatter.h"

@interface StringValueFormatter()

@property (nonatomic, strong) NSArray *dataArray;

@end

@implementation StringValueFormatter

- (id)initWithData:(NSArray<NSString*>*)array
{
    self = [super init];
    if (self) {
        self.dataArray = array;
    }
    return self;
}

- (NSString * _Nonnull)stringForValue:(double)value entry:(ChartDataEntry * _Nonnull)entry dataSetIndex:(NSInteger)dataSetIndex viewPortHandler:(ChartViewPortHandler * _Nullable)viewPortHandler
{
    NSInteger index = (NSInteger )entry.x;
    if(_dataArray && index < _dataArray.count)
        return _dataArray[index];
    else
        return @"";
}

@end
